<?php
session_start();
include("../db_connect.php");
include("../class/objName.php");
$uid = mysql_real_escape_string(htmlentities(trim($_SESSION['id'])));
$obj = new objName();
$item_display = "";
$name = "";
$sql = mysql_query("SELECT * FROM tblpayment where user_id = '$uid'")or die(mysql_query());
if(mysql_num_rows($sql)<1){
	echo '<div style="padding:10px;"><h3 style="color:white;" >No Item Found</h3></div>';
	die();
}
else {
	
	while($rows = mysql_fetch_array($sql)){
		$item_id = 	$rows['item_id'];
		$id = $rows['transaction_id'];
		$qty 	 =	$rows['qty'];
		$txn_id	 =	$rows['txn_id'];
		$pdate 	 = 	$rows['purchase_date'];
	
		$sql2 = mysql_query("select * from tblswaping where id='$item_id' ");
		
		if(mysql_num_rows($sql2)<1){
			$item_display .= '<div id="acc_'.$id.'" style="padding:10px;"><font style="color:white;" >Item code'.$item_id.' have been remove</font><a href="#" onclick="delMyitem('.$id.')" style="color:red" id="item_delete" name="'.$id.'" > x</a></div>';
		
		}
		else{
			while($row = mysql_fetch_array($sql2)){
				
				
				$img = $obj->displayimg($row['filename'],true);
				$item_display .= "	<tr style=' border: 1px solid white;'>";
				$item_display .= "<td valign='top' width='100px'>
					<img id='' style='width:200px; height:90px;' src='images/vehicles/$img'>";
														 
				$item_display .= "<p>Name:".$row['name']."</br> Purchase date:".$pdate."</br>
				<a href='preview.php?from=profile&pageid=".$row['id']."' style='color:red'>Preview</a>|
				<a href='#' onclick='delMyitem(".$id.")' style='color:red' id='item_delete' name='".$id."' >Delete</a></p>
				</div></td>";
				$item_display .="<td valign='top' width='130'><div width='100%'>
				<p>Item code:". $item_id."</p>
				<p>Qty purchase:".$qty." </p>
				<p>Transaction id:</br>".$txn_id."</p>
				<p>Price: ".$row['price']."  </p>
				<p>Condition: ".$row['conditions']." </p>
				<p>Categories: ".$row['categories']."  </p>
				<p>Parts: ".$row['cparts']."  </p>";
				$item_display .= "</div></td>";
				$item_display .="<td valign='top' ><div style='width:280px; height:230px; overflow:auto;'><p align='justify'>" .$row['description']."</p></div></td>";
				$item_display .="</tr>";	
			
			}
		}
	
		
		
		
	}

}

?>

<style>
 #tbl_buyed_item tr { 
        display: table;            /* this makes borders/margins work */
        border: 1px solid black;
       	width:100%;
		margin: 2px 0px 0px 0px;
		color:white;
	}

</style>
<table id="tbl_buyed_item" width="100%">
<tr class='header'>
	<td width="200px">Image</td><td>Description</td><td>Description</td>
</tr>

<?php
echo $item_display;

?>
	
</table>




